package com.example.newheze.User;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.newheze.R;

import java.util.List;

public class ListViewAdapter extends BaseAdapter {
    private List<ListViewModel> mData;
    private Context context;
    public ListViewAdapter(Context context, List mData){
        this.mData=mData;
        this.context=context;
    }
    //item个数
    public int getCount() {
        return mData.size();
    }

    //根据position获取item的数据
    public Object getItem(int i) {
        return mData.get(i);
    }
    //获取item的id
    public long getItemId(int i) {
        return 0;
    }
    //创建列表item的视图
    public View getView(int i, View view, ViewGroup viewGroup) {
        View myview=View.inflate(context, R.layout.user_list_content,null);
        ListViewModel listViewModel =mData.get(i);
        TextView textViewuser=myview.findViewById(R.id.user);
        TextView textView=myview.findViewById(R.id.tv_user_name);
        textViewuser.setText(listViewModel.getUser());
        textView.setText(listViewModel.getUsername());
        return myview;
    }
}
